﻿package mortal.game.manager
{
    import com.gengine.global.*;
    import flash.display.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class UILayer extends View implements ILayer
    {

        public function UILayer()
        {
            tabChildren = false;
            mouseEnabled = false;
            return;
        }// end function

        public function addPopUp(param1:DisplayObject, param2:Boolean = false) : void
        {
            if (param1 && this.contains(param1) == false)
            {
                this.addChild(param1);
                this.layerChange();
            }
            return;
        }// end function

        public function centerPopup(param1:DisplayObject) : void
        {
            param1.x = (Global.stage.stageWidth - param1.width) / 2;
            param1.y = (Global.stage.stageHeight - param1.height) / 2;
            return;
        }// end function

        public function setPosition(param1:DisplayObject, param2:int, param3:int) : void
        {
            param1.x = param2;
            param1.y = param3;
            return;
        }// end function

        public function isTop(param1:DisplayObject) : Boolean
        {
            if (this.contains(param1))
            {
                return this.getChildIndex(param1) == (this.numChildren - 1);
            }
            return false;
        }// end function

        public function removePopup(param1:DisplayObject, param2:Boolean = true) : void
        {
            if (this.contains(param1))
            {
                this.removeChild(param1);
                this.layerChange();
            }
            return;
        }// end function

        public function isPopup(param1:DisplayObject) : Boolean
        {
            return this.contains(param1);
        }// end function

        public function setTop(param1:DisplayObject) : void
        {
            if (this.contains(param1) && param1.parent == this)
            {
                if (this.getChildIndex(param1) != (this.numChildren - 1))
                {
                    this.setChildIndex(param1, (this.numChildren - 1));
                    this.layerChange();
                }
            }
            return;
        }// end function

        public function resize(param1:Number, param2:Number) : void
        {
            var _loc_3:DisplayObject = null;
            var _loc_4:int = 0;
            while (_loc_4 < numChildren)
            {
                
                _loc_3 = this.getChildAt(_loc_4);
                if (_loc_3 is IView)
                {
                    _loc_3.x = _loc_3.x * param1;
                    _loc_3.y = _loc_3.y * param2;
                }
                _loc_4++;
            }
            return;
        }// end function

        protected function layerChange() : void
        {
            return;
        }// end function

    }
}
